/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.restaurant.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;

/**
 *
 * @author Dexter
 */
@Entity
@Table(name = "Persons")
@NamedQueries({
    @NamedQuery(name = "Persons.findAll", query = "SELECT p FROM Persons p"),
    @NamedQuery(name = "Persons.findByPersonId", query = "SELECT p FROM Persons p WHERE p.personId = :personId"),
    @NamedQuery(name = "Persons.findByFirstName", query = "SELECT p FROM Persons p WHERE p.firstName = :firstName"),
    @NamedQuery(name = "Persons.findByLastName", query = "SELECT p FROM Persons p WHERE p.lastName = :lastName"),
    @NamedQuery(name = "Persons.findByEmail", query = "SELECT p FROM Persons p WHERE p.email = :email"),
    @NamedQuery(name = "Persons.findByPhoneNumber", query = "SELECT p FROM Persons p WHERE p.phoneNumber = :phoneNumber"),
    @NamedQuery(name = "Persons.findByStreet", query = "SELECT p FROM Persons p WHERE p.street = :street"),
    @NamedQuery(name = "Persons.findByAddress", query = "SELECT p FROM Persons p WHERE p.address = :address"),
    @NamedQuery(name = "Persons.findByCity", query = "SELECT p FROM Persons p WHERE p.city = :city"),
    @NamedQuery(name = "Persons.findByPostCode", query = "SELECT p FROM Persons p WHERE p.postCode = :postCode"),
    @NamedQuery(name = "Persons.findByLogin", query = "SELECT p FROM Persons p WHERE p.login = :login"),
    @NamedQuery(name = "Persons.findByPassword", query = "SELECT p FROM Persons p WHERE p.password = :password")})
public class Persons implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PersonId")
    private Long personId;
    @Size(max = 80)
    @Column(name = "FirstName")
    private String firstName;
    @Size(max = 80)
    @Column(name = "LastName")
    private String lastName;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 100)
    @Column(name = "Email")
    private String email;
    @Size(max = 12)
    @Column(name = "PhoneNumber")
    private String phoneNumber;
    @Size(max = 120)
    @Column(name = "Street")
    private String street;
    @Size(max = 5)
    @Column(name = "Address")
    private String address;
    @Size(max = 80)
    @Column(name = "City")
    private String city;
    @Size(max = 8)
    @Column(name = "PostCode")
    private String postCode;
    @Size(max = 20)
    @Column(name = "Login")
    private String login;
    @Size(max = 80)
    @Column(name = "Password")
    private String password;
    @OneToMany(mappedBy = "personId", fetch = FetchType.LAZY)
    private List<Reservations> reservationsList;
    @OneToMany(mappedBy = "personId", fetch = FetchType.LAZY)
    private List<Orders> ordersList;
    @JoinColumn(name = "PersonStatusId", referencedColumnName = "PersonStatusId")
    @ManyToOne(fetch = FetchType.LAZY)
    private PersonStatuses personStatusId;

    public Persons() {
    }

    public Persons(Long personId) {
        this.personId = personId;
    }

    public Long getPersonId() {
        return personId;
    }

    public void setPersonId(Long personId) {
        this.personId = personId;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getPostCode() {
        return postCode;
    }

    public void setPostCode(String postCode) {
        this.postCode = postCode;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<Reservations> getReservationsList() {
        return reservationsList;
    }

    public void setReservationsList(List<Reservations> reservationsList) {
        this.reservationsList = reservationsList;
    }

    public List<Orders> getOrdersList() {
        return ordersList;
    }

    public void setOrdersList(List<Orders> ordersList) {
        this.ordersList = ordersList;
    }

    public PersonStatuses getPersonStatusId() {
        return personStatusId;
    }

    public void setPersonStatusId(PersonStatuses personStatusId) {
        this.personStatusId = personStatusId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personId != null ? personId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persons)) {
            return false;
        }
        Persons other = (Persons) object;
        if ((this.personId == null && other.personId != null) || (this.personId != null && !this.personId.equals(other.personId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.restaurant.entities.Persons[ personId=" + personId + " ]";
    }
    
}
